﻿using Microsoft.Xna.Framework;
using GameLibrary;

namespace Rescue_of_the_Dwarvenzombies.SceneObjects.GameObjects
{
    public abstract class GameObject : ISceneObject
    {
        #region Variables

        protected Rectangle sourceRectangle;

        #endregion Variables

        #region Properties

        /// <summary>
        /// Gets or sets the bounding box.
        /// </summary>
        /// <value>
        /// The bounding box.
        /// </value>
        public BoundingBox BoundingBox { get; set; }

        /// <summary>
        /// Gets or sets the previous action.
        /// </summary>
        /// <value>
        /// The previous action.
        /// </value>
        public Constant.Action PreviousAction { get; set; }

        /// <summary>
        /// Gets or sets the direction.
        /// </summary>
        /// <value>
        /// The direction.
        /// </value>
        public Constant.Direction Direction { get; set; }

        /// <summary>
        /// Gets or sets the color of the tint.
        /// </summary>
        /// <value>
        /// The color of the tint.
        /// </value>
        public Color TintColor { get; set; }

        /// <summary>
        /// Gets or sets the source rectangle.
        /// </summary>
        /// <value>
        /// The source rectangle.
        /// </value>
        public Rectangle SourceRectangle { get { return sourceRectangle; } set { sourceRectangle = value; } }

        /// <summary>
        /// Gets or sets the name of the texture.
        /// </summary>
        /// <value>
        /// The name of the texture.
        /// </value>
        public string TextureName { get; set; }

        /// <summary>
        /// Gets or sets the position.
        /// </summary>
        /// <value>
        /// The position.
        /// </value>
        public Vector2 Position { get; set; }

        /// <summary>
        /// Gets or sets the last position.
        /// </summary>
        /// <value>
        /// The last position.
        /// </value>
        public Vector2 LastPosition { get; set; }

        /// <summary>
        /// Gets or sets the wanted move.
        /// </summary>
        /// <value>
        /// The wanted move.
        /// </value>
        public Vector2 WantedMove { get; protected set; }

        /// <summary>
        /// Gets or sets the wanted action.
        /// </summary>
        /// <value>
        /// The wanted action.
        /// </value>
        public Constant.Action WantedAction { get; protected set; }

        /// <summary>
        /// Gets or sets the height of the rectangle.
        /// </summary>
        /// <value>
        /// The height of the rectangle.
        /// </value>
        public int RectangleHeight { get; protected set; }

        /// <summary>
        /// Gets or sets the rectangle offset X.
        /// </summary>
        /// <value>
        /// The rectangle offset X.
        /// </value>
        public int RectangleOffsetX { get; protected set; }

        /// <summary>
        /// Gets or sets the rectangle offset Y.
        /// </summary>
        /// <value>
        /// The rectangle offset Y.
        /// </value>
        public int RectangleOffsetY { get; protected set; }

        /// <summary>
        /// Gets or sets the total width of the texture.
        /// </summary>
        /// <value>
        /// The total width of the texture.
        /// </value>
        public int TotalTextureWidth { get; protected set; }

        /// <summary>
        /// Gets or sets the width of the rectangle.
        /// </summary>
        /// <value>
        /// The width of the rectangle.
        /// </value>
        public int RectangleWidth { get; protected set; }

        /// <summary>
        /// Gets or sets the pixel data.
        /// </summary>
        /// <value>
        /// The pixel data.
        /// </value>
        public Color[] PixelData { get; set; }

        #endregion Properties

        /// <summary>
        /// Initializes a new instance of the <see cref="GameObject"/> class.
        /// </summary>
        protected GameObject()
        {
            WantedAction = Constant.Action.DoNothing;
        }

        /// <summary>
        /// Updates the specified game time.
        /// </summary>
        /// <param name="gameTime">The game time.</param>
        public virtual void Update(GameTime gameTime)
        {
        }

        /// <summary>
        /// Takes the damage.
        /// </summary>
        /// <param name="damage">The damage.</param>
        public virtual void TakeDamage(float damage)
        {
        }

        /// <summary>
        /// Gets the damage.
        /// </summary>
        /// <returns></returns>
        public virtual float GetDamage()
        {
            //As a default, game objects doesn't have a damage.
            //Override in concrete classes to deal damage on collision
            return 0;
        }        
    }
}